

function main22222() {
    let base;
    let do_dlopen = null;
    let call_ctor = null;
    const target_lib_name = 'liblayaair.so';

    Process.findModuleByName('linker64').enumerateSymbols().forEach(sym => {
        if (sym.name.indexOf('do_dlopen') >= 0) {
            do_dlopen = sym.address;
        } else if (sym.name.indexOf('call_constructor') >= 0) {
            call_ctor = sym.address;
        }
    })

    Interceptor.attach(do_dlopen, function (args) {
        if (args[0].readUtf8String().indexOf(target_lib_name) >= 0) {
            Interceptor.attach(call_ctor, function () {
                const module = Process.findModuleByName(target_lib_name);
                base = module.base;
                console.log('loading', target_lib_name, '- base @', base);
            
            // DoStuff
            })
        }
    })
}
function main() {
    var NewStringUTF_addr = null
    console.log('1111111111111')
    var symbols = Process.findModuleByName("liblayaair.so").enumerateExports()
    // console.log(symbols)
    // console.log(symbols.length)

 
    var ch1 = null
    try{
        for (var i in symbols) {
            var symbol = symbols[i]
            if (symbol.name.indexOf("_ZN4laya9JCEncrypt7decryptEPci") >= 0 ){
               console.log("find target symbols", symbol.name, "address is ", symbol.address)
               Interceptor.attach(symbol.address , {
                onEnter: function (args) {
                    ch1 = args[0]
                    console.log( hexdump(ch1))
                    console.log('call--->decrypt',ch1)
                },
                onLeave: function (ret) {
                    console.log( hexdump(ch1))
                 
                }
            })
            }
        }
    }catch(e){}


// console.log("NewStringUTF_addr is ", NewStringUTF_addr);

}

let sleep = function(fun,time){
    setTimeout(()=>{
      main();
    },time);
}
  
sleep(main,10000)

// setImmediate(main22222)

// frida -U --no-pause -f com.shengshu04.yy -l testlaya.js